package com.hliushi.state.example01_right;

/**
 * 红灯状态
 *
 * @author: hliushi
 * @date: 2023/2/15 22:49
 **/
public class RedLight implements State {

    @Override
    public void switchToRed(TrafficLight trafficLight) {
        throw new UnsupportedOperationException("已经是红灯状态无须再切换!!!");
    }

    @Override
    public void switchToGreen(TrafficLight trafficLight) {
        throw new UnsupportedOperationException("红灯不能切换为绿灯");
    }

    @Override
    public void switchToYellow(TrafficLight trafficLight) {
        trafficLight.setState(new YellowLight());
        System.out.println("OK... 黄灯亮起5秒");
    }

    @Override
    public String currentState() {
        return "🟥";
    }
}
